<?php
/**
 * Created by PhpStorm.
 * User: xieky
 * Date: 2017/7/12
 * Time: 11:45
 */

namespace common\repositories\myhtsq;

use common\repositories\BaseRepository;
use common\entities\myhtsq\ContractPayoverEntity;

class ContractPayoverRepository extends BaseRepository
{
    /**
     * 构造方法
     * @param unknown $config (optional)
     */
    public function __construct($config = [])
    {
        parent::__construct($config);
    }

    public static function getContractPayoverInfoByContractId($contractid)
    {
        $query=ContractPayoverEntity::find()
            ->where(['contract_id'=>$contractid])
            ->asArray()
            ->all();
        return $query;
    }

    public static function getContractPayoverInfoByContractCode($contractcode)
    {
        $query=ContractPayoverEntity::find()
            ->where(['contract_code'=>$contractcode])
            ->asArray()
            ->all();
        return $query;
    }

    /**
     * @param $contract_id
     * @return float
     */
    public static function getApplicationPayOverAmountSum($contract_id){
        $sum = ContractPayoverEntity::find()
            ->where(['contract_id'=>$contract_id])->sum('balance_amount');
        return floatval($sum);
    }
}